home *** CD-ROM | disk | FTP | other *** search
/ C# & Game Programming - A…er's Guide (2nd Edition) / Buono 2nd Ed.iso / Chapter2 / 2.7 / 2.7.cs next >
Encoding:
Text File  |  2004-08-31  |  696 b   |  23 lines

  1. /* A compound if statement. */
  2. using System;
  3.  
  4. namespace Chapter2 {
  5.     class Class1 {
  6.         static void Main() {
  7.             string input;
  8.             float MyNumber;                
  9.             
  10.             Console.WriteLine("How old are you? "); 
  11.             input = Console.ReadLine();
  12.             MyNumber = float.Parse(input);
  13.                                     
  14.             if (MyNumber >= 18) {   // compound statement
  15.                 Console.WriteLine("\n You're an adult");   
  16.                 Console.WriteLine("You can vote\n");
  17.             } else                                 
  18.                 Console.WriteLine("\n Your turn will come");
  19.         }
  20.     }
  21. }
  22.  
  23.